package ac2.util.serial;


import java.io.IOException;

import net.tinyos.packet.*;
import net.tinyos.util.*;
import ac2.util.serial.packets.*;

public class PacketSender {
	public static void send(IBytePacket packet, String mote)
	{
		//PacketSource writer = BuildSource.makePacketSource(System.getenv("MOTECOM"));
		PacketSource writer = BuildSource.makePacketSource(mote);
		
		try {
			writer.open(PrintStreamMessenger.err);
			
			byte[] bytes = packet.getBytes();
			Dump.printPacket(System.out, bytes);
			
			writer.writePacket(bytes);
			System.out.println();
			writer.close();
		} catch (IOException e) {
			System.out.println(e.getMessage());
		}
		
	}
}
